package com.shlh.saas;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.event.EventListener;
import org.springframework.core.env.Environment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;

/**
 * 外贸系统应用主类
 */
@SpringBootApplication
@EnableScheduling // 启用定时任务支持
@Slf4j
public class SaasSystemApplication {

    @Autowired
    private Environment environment;

    public static void main(String[] args) {
        SpringApplication.run(SaasSystemApplication.class, args);
    }
    
    /**
     * 应用启动完成后执行
     * 输出当前活动的环境信息
     */
    @EventListener(ApplicationReadyEvent.class)
    public void onApplicationReady() {
        String[] activeProfiles = environment.getActiveProfiles();
        String profiles = String.join(", ", activeProfiles);
        String defaultProfile = environment.getProperty("spring.profiles.active", "default");
        
        if (activeProfiles.length == 0) {
            log.info("应用启动完成，当前未设置任何环境，使用默认环境: {}", defaultProfile);
        } else {
            log.info("应用启动完成，当前活动环境: {}", profiles);
        }
        
    }
} 